package erp_services

import (
	"errors"
	"xiehui-service/app/common/request"
	"xiehui-service/app/models/erp_models"
	"xiehui-service/global"
)

type orderDispatchService struct {
}

var OrderDispatchService = new(orderDispatchService)

// 获取信息
func (orderDispatchService *orderDispatchService) GetOneInfo(params request.List) (orderTask *erp_models.OrderTask, err error) {
	err = global.App.DB.First(&orderTask, params.Id).Error
	if err != nil {
		orderTask = nil
		if err.Error() == "record not found" {
			err = errors.New("数据不存在")
		}
	}
	return
}

func (orderDispatchService *orderDispatchService) GetOrderTaskByUnioNo(unionNo string) (orderTask erp_models.OrderTask, err error) {
	err = global.App.DB.Where("union_no = ? ", unionNo).Find(&orderTask).Error

	if err != nil {
		if err.Error() == "record not found" {
			err = errors.New("数据不存在")
		}
	}
	return
}
